package com.lilicould.dao;

import com.lilicould.entity.GradeDetails;
import com.lilicould.entity.Grades;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface GradeDao {

    @Select("select * from student_grades_view where student_no=#{userNo}")
    List<GradeDetails> getGradesByUserNo(String userNo);

    // 根据课程安排ID查询成绩信息，即使学生成绩未录入
    List<GradeDetails> getGradesByScheduleId(int scheduleId);

    @Insert("INSERT INTO grades (student_user_no, course_id, teacher_user_no, semester, score, exam_date) VALUES (#{studentUserNo}, #{courseId}, #{teacherUserNo}, #{semester}, #{score}, #{examDate})")
    int addGrade(Grades grade);

    @Update("UPDATE grades SET score=#{score},exam_date = #{examDate} WHERE id=#{id}")
    int updateGrade(Grades grade);

}
